asm
  ld sp,$FFFF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"
#include "./library/pacmanldir.bas"
#include "./library/pacmanfillram.bas"
#include "./library/charmapkontest01.bas"

dim eee as uinteger at $E010
dim seed as uinteger at $E012
dim delay as uinteger at $E014
dim eex as uinteger at $E016
dim eey as uinteger at $E018
dim ee1 as uinteger at $E01A
dim ee2 as uinteger at $E01C
dim ee3 as uinteger at $E01E
dim ee4 as uinteger at $E020


sub kontestputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte)
  poke $E8A0+txp1+(typ1*64),tch1
  end sub

sub kontestputattr(txp1 as uinteger,typ1 as uinteger,tat1 as ubyte)
  poke $E060+txp1+( (int(typ1/2)) *64),tat1
  end sub

sub kontestputcharattr(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte)
  poke $E8A0+txp1+(typ1*64),tch1
  poke $E060+txp1+( (int(typ1/2)) *64),tat1
  end sub

seed=0
pacmanldir($F200,@charmap01,77*16)

for eey=0 to 27
  for eex=0 to 31
    seed=smsrnd(seed):ee4=seed:seed=smsrnd(seed)
    kontestputcharattr(eex,eey,$60+(seed mod 13),ee4)
    next:next

for eey=0 to 15
  for eex=0 to 15
    kontestputcharattr(eex+15,eey+10,(eey*16)+eex,0)
    next:next

eex=8:eey=8

eee=0
do
  kontestputcharattr(1,2,48+(int(eee/100) mod 10),0)
  kontestputcharattr(2,2,48+(int(eee/10) mod 10),0)
  kontestputcharattr(3,2,48+(eee mod 10),0)

  ee4=in($0C) bxor 255
  kontestputcharattr(1,4,48+(int(ee4/100) mod 10),0)
  kontestputcharattr(2,4,48+(int(ee4/10) mod 10),0)
  kontestputcharattr(3,4,48+(ee4 mod 10),0)

  eex=eex-((ee4 band 4)/4)+((ee4 band 8)/8)
  eey=eey-((ee4 band 1)/1)+((ee4 band 2)/2)
  kontestputcharattr(eex,eey,32+(eee mod 80),2)

  ee4=in($0D) bxor 255
  kontestputcharattr(1,5,48+(int(ee4/100) mod 10),0)
  kontestputcharattr(2,5,48+(int(ee4/10) mod 10),0)
  kontestputcharattr(3,5,48+(ee4 mod 10),0)

  ee4=in($0E) bxor 255
  kontestputcharattr(1,6,48+(int(ee4/100) mod 10),0)
  kontestputcharattr(2,6,48+(int(ee4/10) mod 10),0)
  kontestputcharattr(3,6,48+(ee4 mod 10),0)

  ee4=in($0F) bxor 255
  kontestputcharattr(1,7,48+(int(ee4/100) mod 10),0)
  kontestputcharattr(2,7,48+(int(ee4/10) mod 10),0)
  kontestputcharattr(3,7,48+(ee4 mod 10),0)
  
  eee=eee+1
  smsdelay(100)
  loop



do:loop


'-------------------------------------------------

